home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / dev / lang / SmallEiffel.lha / SmallEiffel / lib_se / character_constant.e < prev    next >
Text File  |  1998-12-22  |  3KB  |  138 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  4. --                       http://www.loria.fr/SmallEiffel
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it 
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later 
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License 
  11. -- for  more  details.  You  should  have  received a copy of the GNU General 
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class CHARACTER_CONSTANT
  17. --
  18. -- For Manifest Constant CHARACTER.
  19. --   
  20.  
  21. inherit
  22.    BASE_TYPE_CONSTANT
  23.       redefine to_integer
  24.       end;
  25.    
  26. creation {EIFFEL_PARSER}
  27.    make
  28.  
  29. feature
  30.    
  31.    value: CHARACTER;
  32.  
  33. feature
  34.    
  35.    pretty_print_mode: INTEGER;
  36.    
  37.    std_pretty_print: INTEGER is 0;
  38.    
  39.    percent_pretty_print: INTEGER is 1;
  40.    
  41.    ascii_pretty_print: INTEGER is 2;
  42.    
  43.    c_simple: BOOLEAN is true;
  44.  
  45.    is_static: BOOLEAN is true;
  46.  
  47. feature
  48.  
  49.    make(sp: like start_position; v: like value; 
  50.     pm: like pretty_print_mode) is
  51.       require
  52.      sp /= Void;
  53.       do
  54.      start_position := sp;
  55.      value := v;
  56.      set_pretty_print_mode(pm);
  57.       ensure
  58.      start_position = sp;
  59.      value = v;
  60.      pretty_print_mode = pm;
  61.       end;
  62.    
  63.    static_value, to_integer: INTEGER is
  64.       do
  65.      Result := value.code;
  66.       end;
  67.    
  68.    compile_to_c is
  69.       do
  70.      cpp.put_character('%'');
  71.      if value.is_letter or else value.is_digit then
  72.         cpp.put_character(value);
  73.      elseif value = '%N' then
  74.         cpp.put_character('\');
  75.         cpp.put_character('n');
  76.      else
  77.         cpp.put_character('\');
  78.             cpp.put_integer(value.code.to_octal);
  79.      end;
  80.      cpp.put_character('%'');
  81.       end;
  82.    
  83.    compile_to_jvm, compile_target_to_jvm is
  84.       do
  85.      code_attribute.opcode_push_integer(value.code);
  86.       end;
  87.    
  88.    jvm_branch_if_false: INTEGER is
  89.       do
  90.       end;
  91.  
  92.    jvm_branch_if_true: INTEGER is
  93.       do
  94.       end;
  95.    
  96.    compile_to_jvm_into(dest: TYPE): INTEGER is
  97.       do
  98.      Result := standard_compile_to_jvm_into(dest);
  99.       end;
  100.  
  101.    set_pretty_print_mode(pm: like pretty_print_mode) is
  102.       require
  103.      pm = std_pretty_print or else
  104.      pm = percent_pretty_print or else
  105.      pm = ascii_pretty_print
  106.       do
  107.      pretty_print_mode := pm;
  108.       ensure      
  109.      pretty_print_mode = pm;
  110.       end;
  111.  
  112.    to_string: STRING is
  113.       do
  114.      !!Result.make(0);
  115.      Result.extend('%'');
  116.      inspect 
  117.         pretty_print_mode
  118.      when std_pretty_print then
  119.         Result.extend(value);
  120.      when percent_pretty_print then
  121.         character_coding(value,Result);
  122.      when ascii_pretty_print then
  123.         Result.extend('%%');
  124.         Result.extend('/');
  125.         value.code.append_in(Result);
  126.         Result.extend('/');
  127.      end;
  128.      Result.extend('%'');
  129.       end;
  130.    
  131.    result_type: TYPE_CHARACTER is
  132.       once
  133.      !!Result.make(Void);
  134.       end;
  135.    
  136. end -- CHARACTER_CONSTANT
  137.  
  138.